package com.example.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.entity.basics.BasicsEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author ptuDai
 * @since 2022-03-05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("menu")
public class Menu extends BasicsEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 父菜单ID，一级菜单为0
     */
    @NotNull(message = "父菜单不能为空")
    @TableField(value = "parent_id")
    private Integer parentId;
    @NotBlank(message = "名称不能为空")
    @TableField(value = "name")
    private String name;
    @NotBlank(message = "标题不能为空")
    @TableField(value = "title")
    private String title;

    /**
     * 菜单URL
     */
    @TableField(value = "path")
    private String path;
    @TableField(value = "component")
    private String component;

    /**
     * 授权(多个用逗号分隔，如：user:list,user:create)
     */
    @TableField(value = "perms")
    private String perms;

    /**
     * 类型 0：目录 1：菜单 2：按钮
     */
    @TableField(value = "type")
    private Integer type;

    /**
     * 菜单图标
     */
    @TableField(value = "icon")
    private String icon;

    /**
     * 排序
     */
    @TableField(value = "order_num")
    private Integer orderNum;

    /**
     * 菜单状态
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * 子级菜单
     */
    @TableField(exist = false)
    private List<Menu> children = new ArrayList<>();


}
